package com.jiangyg.devtools.ui.table.cell;

import com.intellij.openapi.project.Project;
import com.intellij.ui.components.JBTextField;

import javax.swing.*;
import java.awt.*;

/**
 * 类描述：文本单元格编辑器
 *
 * @author jiangyg
 * @date 2023-08-29
 */
public class TextFieldCellEditor extends AbstractTableCellEditor {

    private final JBTextField textField = new JBTextField();

    public TextFieldCellEditor(Project project) {
        super(project);
    }

    @Override
    public Component getTableCellEditorComponent(JTable table,
                                                 Object value,
                                                 boolean isSelected,
                                                 int row, int column) {
        textField.setText(String.valueOf(value));
        return textField;
    }

    @Override
    public Object getCellEditorValue() {
        return textField.getText();
    }

}
